package com.flying.arts.common.domain.entity;

import org.apache.commons.beanutils.BeanUtils;

public class BaseEntity<T> extends Entity<T> {
    private boolean isModified;

    public BaseEntity(T id) {
        super.setId(id);
        setModified(false);
    }

    private void setModified(boolean modified) {
        isModified = modified;
    }

    @Override
    public void setId(T id) {
        super.setId(id);
        setModified(true);
    }

    public boolean isModified() {
        return isModified;
    }

    @Override
    public String toString() {
        try {
            return BeanUtils.describe(this).toString();
        } catch (Exception e) {
            e.printStackTrace();
            return (e.getMessage());
        }
    }
}
